package org.hadoop.spark

import org.apache.spark.SparkConf
import org.apache.spark.streaming.{Seconds, StreamingContext}

object Streaming2 {
  def main(args: Array[String]): Unit = {
    val conf: SparkConf = new SparkConf();
    conf.set("fs.defaultFS", "hdfs://server102:8020");
    conf.setAppName("Streaming01");
    val streamingContext: StreamingContext = new StreamingContext(conf, Seconds(5));
    var lines = streamingContext.socketTextStream("server102", 4444);
    lines.print();
    lines.saveAsTextFiles("hdfs://server102:8020/out001/a");
    streamingContext.start();
    streamingContext.awaitTermination();
  }
}
